package com.yang.newCustomersTransferBackProcess.controller;

import com.yang.newCustomersTransferBackProcess.pojo.MergeCustomer;
import com.yang.newCustomersTransferBackProcess.service.MergeCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class MergeCustomerController {

    @Autowired
    private MergeCustomerService mergeCustomerService;

    @PostMapping("/mergeToExamine")
    public Map<String, Object> mergeToExamine(@RequestParam(name = "mergeCustomerId") int mergeCustomerId,
                                                              @RequestParam(name = "pass")String pass
    ){

        return mergeCustomerService.mergeToExamine(mergeCustomerId, pass);
    }

    @PostMapping("/merge")
    public Map<String, Object> merge(@RequestParam(name = "mergeCustomerId") int mergeCustomerId
    ){

        return mergeCustomerService.merge(mergeCustomerId);
    }

    @PostMapping("/queryMergeCustomer")
    public List<MergeCustomer> queryMergeCustomer(
    ){

        return mergeCustomerService.queryMergeCustomer();
    }

    @PostMapping("/toApplyFor")
    public Map<String, Object> toApplyFor(
                                          @RequestParam(name = "needConsolidateCustomerId") int needConsolidateCustomerId,
                                          @RequestParam(name = "needConsolidateCustomername") String needConsolidateCustomername,
                                          @RequestParam(name = "keepCustomerId") int keepCustomerId,
                                          @RequestParam(name = "keepCustomerName") String keepCustomerName,
                                          @RequestParam(name = "reason") String reason
    ){

        return mergeCustomerService.toApplyFor(
                needConsolidateCustomerId,
                needConsolidateCustomername,
                keepCustomerId,
                keepCustomerName,
                 reason);
    }
}
